<template>
  <div class="bg-white common-card">
    <dc-cell class="main-title" title="风险稽核" value="详情" sVal="true" :to="'/riskAudit'" isLink></dc-cell>
    <div class="sub-title">风险操作金额统计</div>
    <div class="common-chart" id="riskcolumn"></div>

  </div>

</template>
<script>
  import cell from '@/components/cell';
  import {initColumn} from '@/common/echarts/column';
  import api from '@/common/api/riskAudit';
  export default {
    components: {
      'dc-cell': cell
    },
    data () {
      return {
        data: {timeFlag: -1},
        riskMoney: {},
        column: null
      };
    },
    methods: {
      _sysGetRisk (data) {
        api.getRiskColumn(data).then(res => {
          if (res) {
            this.riskMoney = res;
            this.initPeriodColumn();
          }
        });
      },
      initPeriodColumn () {
        this.column.hideLoading();
        this.column.setOption({
          color: ['#78ACF2'],
          xAxis: [
            {
              type: 'category',
              data: ['退单', '返位单', '赠单', '宴请']
            }
          ],
          yAxis: [
            {
              type: 'value',
              name: '折前合计',
              nameRotate: 90,
              nameGap: 50,
              nameLocation: 'middle'
            }
          ],
          series: [
            {
              name: '',
              type: 'bar',
              barWidth: '60%',
              data: [this.riskMoney.returnMny || 0, this.riskMoney.cancelMny || 0, this.riskMoney.presentMny || 0, this.riskMoney.zeroMny || 0]
            }
          ]
        });
      }
    },
    mounted () {
      this.column = initColumn('#riskcolumn');
      this.initPeriodColumn();
      this._sysGetRisk(this.data);
    },
    activated () {
      this._sysGetRisk(this.data);
    }
  };
</script>
<style lang="scss" scoped>

</style>
